package com.yanqu.road.server.cmd.activity.tonbingchannel;


import com.yanqu.road.entity.activity.tonbingchannel.config.ChannelTonBingConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ChannelTonBingProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.tonbingchannel.ChannelTonBingMgr;
import com.yanqu.road.server.protocol.ChannelProtocol;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_CTON_BING_SYNC_BASE_DATA, desc = "")
public class TonBingUserDataSyncCmd extends AbstractCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ChannelTonBingProto.CTonBingSyncBaseDataRespMsg syncMsg = ChannelTonBingProto.CTonBingSyncBaseDataRespMsg.parseFrom(packet.getBytes());
        if (syncMsg.getHavePatrons()) {//标记一下玩家有传过门客苏数据了
            ChannelTonBingMgr.setHavePatrons(packet.getPlayerId(), true);
        }
        player.sendPacket(ClientProtocol.U_CTON_BING_SYNC_BASE_DATA, syncMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret == 0) {
            return;
        }

        ChannelTonBingProto.CTonBingGetDataRespMsg.Builder respMsg = ChannelTonBingProto.CTonBingGetDataRespMsg.newBuilder();
        respMsg.setRet(ret);
        player.sendPacket(ClientProtocol.U_CTON_BING_GET_DATA, respMsg);
    }
}
